package models

import (
	"fmt"
	"github.com/zeromicro/go-zero/core/conf"
	"gorm.io/driver/mysql"
	"gorm.io/gorm"
	"zg4_month_exam/user/rpc/internal/config"
)

var db = &gorm.DB{}

func init() {
	var err error
	var c config.Config
	conf.Load("etc/user.yaml", &c)
	dsn := c.Mysql.Datasource
	db, err = gorm.Open(mysql.Open(dsn), &gorm.Config{})
	if err != nil {
		fmt.Println("数据库连接", err.Error())
	}
}
